package com.bah.tract.client.ui.menu;

import java.awt.Image;
import java.awt.MenuItem;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ResourceBundle;

import javax.swing.JDialog;

public class HelpMenuItem extends MenuItem {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JDialog helpDialog = new JDialog();

	public HelpMenuItem() {
		super("Help");
		addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(final ActionEvent e) {
				helpDialog = new JDialog();
				helpDialog.setTitle("TRACT - Help");
				helpDialog.setResizable(false);
				final Image image = Toolkit.getDefaultToolkit().getImage(
						"stopwatch.PNG");
				helpDialog.setIconImage(image);
				helpDialog.getContentPane().add(new MessageJPanel());
				helpDialog.pack();
				helpDialog.setVisible(true);
			}
		});
	}

	private class CloseAction implements ActionListener {

		@Override
		public void actionPerformed(final ActionEvent e) {
			helpDialog.setVisible(false);
		}

	}

	/**
	 * 
	 * @author 524506
	 */
	private class MessageJPanel extends javax.swing.JPanel {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		/** Creates new form NewJPanel */
		public MessageJPanel() {
			initComponents();
		}

		/**
		 * This method is called from within the constructor to initialize the
		 * form. WARNING: Do NOT modify this code. The content of this method is
		 * always regenerated by the Form Editor.
		 */
		// <editor-fold defaultstate="collapsed" desc="Generated Code">
		private void initComponents() {

			jLabel1 = new javax.swing.JLabel();
			jLabel2 = new javax.swing.JLabel();
			jLabel3 = new javax.swing.JLabel();
			jLabel4 = new javax.swing.JLabel();
			jButton1 = new javax.swing.JButton();
			jButton1.addActionListener(new CloseAction());

			setName("Form"); // NOI18N

			final ResourceBundle resourceMap = ResourceBundle
					.getBundle("com.bah.tract.client.ui.HelpMenu");
			jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
			jLabel1.setName("jLabel1"); // NOI18N

			jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
			jLabel2.setName("jLabel2"); // NOI18N

			jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
			jLabel3.setName("jLabel3"); // NOI18N

			jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
			jLabel4.setName("jLabel4"); // NOI18N

			jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
			jButton1.setName("jButton1"); // NOI18N

			final javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
					this);
			setLayout(layout);
			layout.setHorizontalGroup(layout
					.createParallelGroup(
							javax.swing.GroupLayout.Alignment.LEADING)
					.addGroup(
							layout.createSequentialGroup()
									.addContainerGap()
									.addGroup(
											layout.createParallelGroup(
													javax.swing.GroupLayout.Alignment.LEADING)
													.addComponent(jLabel1)
													.addComponent(jLabel2)
													.addComponent(jLabel3)
													.addComponent(jLabel4))
									.addContainerGap(
											javax.swing.GroupLayout.DEFAULT_SIZE,
											Short.MAX_VALUE))
					.addGroup(
							javax.swing.GroupLayout.Alignment.TRAILING,
							layout.createSequentialGroup()
									.addContainerGap(291, Short.MAX_VALUE)
									.addComponent(jButton1).addContainerGap()));
			layout.setVerticalGroup(layout.createParallelGroup(
					javax.swing.GroupLayout.Alignment.LEADING).addGroup(
					layout.createSequentialGroup()
							.addContainerGap()
							.addComponent(jLabel1)
							.addGap(18, 18, 18)
							.addComponent(jLabel2)
							.addGap(18, 18, 18)
							.addComponent(jLabel3)
							.addGap(18, 18, 18)
							.addComponent(jLabel4)
							.addGap(18, 18, 18)
							.addComponent(jButton1)
							.addContainerGap(
									javax.swing.GroupLayout.DEFAULT_SIZE,
									Short.MAX_VALUE)));
		}// </editor-fold>

		// Variables declaration - do not modify
		private javax.swing.JButton jButton1;
		private javax.swing.JLabel jLabel1;
		private javax.swing.JLabel jLabel2;
		private javax.swing.JLabel jLabel3;
		private javax.swing.JLabel jLabel4;
		// End of variables declaration

	}

}
